package src;

import java.util.Scanner;
import java.util.Random;
public class GuessTheNumber {
    public static void main(String[] args) {
        int a = 0;
        System.out.println("猜数字的游戏开始了!");
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int n = r.nextInt(100)+1;
        while(true) {
            a++;
        System.out.println("在1-100选择一个数字");
        int i = sc.nextInt();
            if (i > n) {
                System.out.println("大了");
            } else if (i < n) {
                System.out.println("小了");
            } else {
                System.out.println("对啦，这个数字就是" + i);
                break;
            }
        }
        System.out.println("你用了"+a+"次");
    }
}